<?php

namespace App\Admin\Controllers;

use App\Tc58detail;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;

class Tc58DetailController extends Controller
{
    use HasResourceActions;

    /**
     * Index interface.
     *
     * @param Content $content
     * @return Content
     */
    public function index(Content $content)
    {
        return $content
            ->header('58同城厂房')
            ->description('58同城厂房')
            ->body($this->grid());
    }

    /**
     * Show interface.
     *
     * @param mixed $id
     * @param Content $content
     * @return Content
     */
    public function show($id, Content $content)
    {
        return $content
            ->header('58同城厂房')
            ->description('58同城厂房')
            ->body($this->detail($id));
    }

    /**
     * Edit interface.
     *
     * @param mixed $id
     * @param Content $content
     * @return Content
     */
    public function edit($id, Content $content)
    {
        return $content
            ->header('58同城厂房编辑')
            ->description('58同城厂房编辑')
            ->body($this->form()->edit($id));
    }

    /**
     * Create interface.
     *
     * @param Content $content
     * @return Content
     */
    public function create(Content $content)
    {
        return $content
            ->header('新建58同城厂房')
            ->description('新建58同城厂房')
            ->body($this->form());
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Tc58detail);

        $grid->id('Id');
        $grid->area('面积');
        $grid->zdate('更新时间');
        $grid->ptype('付款类型');
        $grid->ctype('类别');
        $grid->high('首层高度');
        $grid->floor('楼层数');
        $grid->address('厂房地址');
        //$grid->atvar('头像');
        $grid->ztype('租聘类型');
        $grid->telephone('联系电话');
        $grid->title('标题');
        $grid->code('厂房编号');
        $grid->price('价格');
        $grid->updated_at('Updated at');
        $grid->compony('所属公司');
        $grid->is_agent('是否经纪人');
        //$grid->slider('厂房图片');
        //$grid->detail('详情');
        $grid->owner('联系人');

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Tc58detail::findOrFail($id));

        $show->id('Id');
        $show->area('面积');
        $show->zdate('更新时间');
        $show->ptype('付款类型');
        $show->ctype('类别');
        $show->high('首层高度(m)');
        $show->floor('楼层数(层)');
        $show->address('厂房地址');
        $show->atvar('头像');
        $show->ztype('租聘类型');
        $show->telephone('联系电话');
        $show->title('标题');
        $show->code('厂房编号');
        $show->price('价格(元/月)');
        $show->updated_at('Updated at');
        $show->compony('所属公司');
        $show->is_agent('是否经纪人');
        $show->slider('厂房图片');
        $show->detail('详情');
        $show->owner('联系人');

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Tc58detail);

        $form->text('area', '面积');
        $form->text('zdate', '更新时间');
        $form->text('ptype', '付款类型');
        $form->text('ctype', '类别');
        $form->text('high', '首层高度');
        $form->text('floor', '楼层数');
        $form->text('address', '厂房地址');
        $form->text('atvar', '头像');
        $form->text('ztype', '租聘类型');
        $form->text('telephone', '联系电话');
        $form->text('title', '标题');
        $form->text('code', '厂房编号');
        $form->text('price', '价格');
        $form->text('compony', '所属公司');
        $form->text('is_agent', '是否经纪人');
        $form->text('slider', '厂房图片');
        $form->text('detail', '详情');
        $form->text('owner', '联系人');

        return $form;
    }
}
